package ar.com.vates.vsp.capitulo3;

import java.util.*;

public class Fifo implements Pila {
	
	ArrayList <Object> fifo=new ArrayList<Object>();
	
	public boolean cargar(Object o){//Cargar cola fifo.
		
		if (fifo.add((Object) o) == true)
        {
            return true;
        }
        return false;
	}
	
	public boolean eliminar(Object o){//eliminar un elemento de la cola fifo y lo muestra.
		
		if(fifo.isEmpty()!=true){
						
		        Iterator <Object> iterator = (Iterator<Object>) fifo.iterator();
		       
		        fifo.remove(0);
		       
		  
		  /*      
		        while (iterator.hasNext())
		        {
		        	if (iterator.next().equals(o)){
		                System.out.println(iterator);
		           return     fifo.remove(o);
		        	}
		            
		        }
		      //  return true;
		    }
		return false;
		
	*/	
		}
	      return true;
	}
	
	public void listar(){
		Iterator<Object> iterator = fifo.iterator();
		  while (iterator.hasNext())
	        {
	            System.out.println(iterator.next().toString());

	        }
	}


	
	
}
